<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache" >
<meta http-equiv="Cache-Control" content="no-cache" >
<meta http-equiv="Expires" content="-1" >
<title>Website Login</title>
<base target="_self" />

<link rel="stylesheet" href="/style/common.css" type="text/css">
<link rel="stylesheet" href="/style/custom.css" type="text/css">
<style type="text/css">
</style>
<script type="text/javascript" src="/opt/script/jquery.js"></script>
<script type="text/javascript" src="/script/common.js"></script>
<script type="text/javascript" src="/opt/script/sha1.js"></script>
<script type="text/javascript">
function initForm() {
	var err = $("#error");
	var f = $("#loginform")
	var fu = $("#username", f);
	var fp = $("#password", f);
	var fn = $("#nonce", f);
	var ts = new Date().getTime();
	if (data) {
		fu.val(data.username);
		fn.val(ts);
		err.text(data.error);
	} else {
		//
		window.location.replace("/login");
	}
	var msg = "Username/password can't be empty";
	f.submit(function() {
		var vu = fu.val();
		var vp = fp.val(); 
		if (vu && vp) {
			var s = b64_sha1(vp);
			var d = b64_sha1(s+":"+data.nonce+":"+ts);
			fp.val(d);
			err.text(""); 
			return true;
		}
		err.text(msg);
     		return false;
	});
	$("#loginform input").blur(function() {
		if(!this.value) {
			err.text(msg);
		}
	});
	$("#loginform input").focus(function() {
		if(!this.value) {
			err.text("");
		}
	});
}
</script>

<script type="text/javascript">
$(document).ready(function(){
	$.fullScreen();
	initForm();
	$.initOptionMenu();
	$.disableContextMenu();
});
</script>
</head>
<body>

<div id="topnav">
	<a class="logo" href="/home" title="Access your phone from a browser.">
	<img class="icon32" src="/icon/info.niwota.web"  alt="Website" >
	<span>Local</span>
	</a>	
	
	<span class="top-right" style="margin-right: 64px;">
	
	<span class="action"><a href="/web/help.html" target="help">Help</a></span>

	</span>
</div>


<div id="page-content" style="text-align:left;">

<div style="margin-top: 16px; ">
<span id="error" style="color: #f00;">  </span>
</div>

<div class="section"> 
<form id="loginform" action="/login" method="post" enctype="application/x-www-form-urlencoded">

User ID:<br />
<input name="username" id="username" size="18" value="" type="text">
<br />
Password:<br />
<input name="password" id="password" size="18" type="password">
<br />
<input name="action" id="action" value="login" type="submit">

<input name="nonce" id="nonce"  value="" type="hidden">

</form>
</div>


</div>


<div id="optionmenu" >
<a href="/home" title="Home" ><img src="/drawable/ic_menu_home" /></a>
<a href="/web/help.html" title="Help" target="help"><img src="/drawable/ic_menu_help" /></a>
</div>

<div id="footer">Website &copy; 2010 All rights reserved</div>

<div id="wallpaper" style="display: block;"><img src="/wallpaper" width="100%" height="100%" /></div>

</body>
</html>